-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update refs.mdx #1127
base: main
Are you sure you want to change the base?
Update refs.mdx #1127
Conversation
Signal value should be used as red, not the signal setter.
|
✅ Deploy Preview for solid-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
<button onClick={() => setShow((isShown) => !isShown)}>Toggle</button> | ||
|
||
<Show when={show()}> | ||
<p ref={setElement}>This is the ref element</p> | ||
<p ref={element}>This is the ref element</p> | ||
</Show> | ||
</div> | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great pickup! looking at the two, there are multiple things that need to be updated within this code snippet from the playground. Do you mind updating it to reflect that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only thing I would add to the code snippet from the playground ist the code from createEffect. The other things looks fine. If you agree, I can update the PR.
Maybe it would be a good thing to change parameter in the setShow function vom (v) => !v to (isShown) => !isShown. What are your thoughts on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the createEffect
itself is necessary. I mostly mean that the code snippet should look like this:
function App() {
const [show, setShow] = createSignal(false);
let element!: HTMLParagraphElement;
return (
<div>
<button onClick={() => setShow((isShown) => !isShown)}>Toggle</button>
<Show when={show()}>
<p ref={element}>This is the ref element</p>
</Show>
</div>
);
}
Since we don't need the setElement
in this, we can do without the signal itself!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, indeed! I will change that accordingly.
<button onClick={() => setShow((isShown) => !isShown)}>Toggle</button> | ||
|
||
<Show when={show()}> | ||
<p ref={setElement}>This is the ref element</p> | ||
<p ref={element}>This is the ref element</p> | ||
</Show> | ||
</div> | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the createEffect
itself is necessary. I mostly mean that the code snippet should look like this:
function App() {
const [show, setShow] = createSignal(false);
let element!: HTMLParagraphElement;
return (
<div>
<button onClick={() => setShow((isShown) => !isShown)}>Toggle</button>
<Show when={show()}>
<p ref={element}>This is the ref element</p>
</Show>
</div>
);
}
Since we don't need the setElement
in this, we can do without the signal itself!
Signal value should be used as red, not the signal setter.
Description(required)
The signals getter should be used as ref, not the signal setter. In the playground it is correct. Just a small mistake in the docs page.
Related issues & labels